import React from 'react'
import {Link,History} from 'react-router'
require("!style!css!../../css/myApp.css");
var Form = ReactUI.Form
var FormControl = ReactUI.FormControl
var Icon = ReactUI.Icon
var Input = ReactUI.Input
var DatepickerPair = ReactUI.DatepickerPair
var Refetch = ReactUI.Refetch
var Modal = ReactUI.Modal
var FormSubmit = ReactUI.FormSubmit
var Button = ReactUI.Button
export default class UserManager extends React.Component {
    constructor() {
        super();
        this.state = {
            formData:null,
        }
    }
    handleSubmit1(formData){
        var dataHeader='{"header":{"business":"addUser","destSystem":"SOAPlat","sourceSystem":"SOAPlat","rootParam":"User"},';
        var dataBody='"body":'+JSON.stringify(formData);
        var data = dataHeader+dataBody+"}";
        $.ajax({
            type: 'POST',
            url:'user/add',
            data: "data="+data,
            dataType:'json',
            success: function(result){
                Modal.alert(result.rtnStr);
                History.push(null,'/userManager');
            },
            error:function(e){
                Modal.alert("操作出错!");

            }
        })

    }
    render() {
        return (
            <div>
                <div className="bg-light lter b-b wrapper-md">
                    <h1 className="m-n font-thin h3">新增用户</h1>
                </div>
                <div className="wrapper-md">
                <Form onSubmit={this.handleSubmit1} button={"提交"} >
                    <FormControl name="username"
                                 label="用户名"
                                 type="text"
                                 required
                                 grid={{width:12/24}}
                                 min={1}
                                 max={18} />
                    <FormControl grid={{width:12/24}}
                                 name="password"
                                 min={6}
                                 max={20}
                                 required
                                 label="密码"
                                 type="password" />
                    <FormControl grid={{width:12/24}}
                                 name="officePhone"
                                 min={6}
                                 max={20}
                                 label="联系电话"
                                 type="text" />
                    <FormControl name="email" label="邮箱" type="email" grid={{width:12/24}}/>
                    <Link to="/userManager" className="btn m-b-xs btn-sm btn-info btn-addon"><i className="fa fa-plus"></i>返回</Link>
                </Form>
                </div>
            </div>

        )
    }
}